<?php

namespace Yolo\ORM;

use DateTimeInterface;
use Hyperf\DbConnection\Model\Model as BaseModel;
use Hyperf\Database\Model\Concerns\CamelCase;

abstract class AbstractModel extends BaseModel
{
    use CamelCase;

    protected ?string $dateFormat = 'U';

    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected array $casts = [
        'id' => 'integer',
        'status' => 'integer',
        'created_at' => 'timestamp',
        'created_by' => 'integer',
        'updated_at' => 'timestamp',
        'updated_by' => 'integer',
    ];

    protected function serializeDate(DateTimeInterface $date): int|string
    {
        return $date->getTimestamp();
    }
}
